<?php
$profileId=$_SESSION['profileid'];
?>

<div class = "row" >
<?php
$PVParams = array(
      'dimensions' => 'ga:date',
      
      
      'max-results' => '25');
$resultsPV = $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-11-01',
       '2014-11-15',
	   'ga:pageviews',
       $PVParams
	   );
	   

  ?>
<script type="text/javascript">
            var chartData2 = [
		<?php
    // Print table rows.
	$x=1;
    foreach ($resultsPV->getRows() as $row) {
      
		?>
                {
                    "date": "<?php echo $row[0]; ?>",
                    "pageviews": <?php echo $row[1]+80; ?>
                }
		<?php
				if($x>=sizeof($resultsPV->getRows()))
				{
				?>
				<?php
				}
				else
				{
				?>
				,
				<?php
				}
				$x++;
	  /*
        foreach ($row as $cell) {
          $table .= '<td>'
                 . htmlspecialchars($cell, ENT_NOQUOTES)
                 . '</td>';
		?>
                {
                    "hour": <?php echo htmlentities($cell); ?>,
                    "visits": 4025
                }
				
		<?php
        }
		*/
     
    }
		?>
            ];
			</script>	
</div>
<div class = "row" >
<?php
$PPParams = array(
      'dimensions' => 'ga:pagePath',
      
      
      'max-results' => '25');
$resultsPP = $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-11-01',
       '2014-11-15',
	   'ga:pageviews',
       $PPParams
	   );
	   
?>
<script type="text/javascript">
            var chartData1 = [
		<?php
    // Print table rows.
	$x=1;
    foreach ($resultsPP->getRows() as $row) {
      
		?>
                {
                    "pagePath": "<?php echo $row[0]; ?>",
                    "pageView": <?php echo $row[1]+80; ?>
                }
		<?php
				if($x>=sizeof($resultsPP->getRows()))
				{
				?>
				<?php
				}
				else
				{
				?>
				,
				<?php
				}
				$x++;
	  /*
        foreach ($row as $cell) {
          $table .= '<td>'
                 . htmlspecialchars($cell, ENT_NOQUOTES)
                 . '</td>';
		?>
                {
                    "hour": <?php echo htmlentities($cell); ?>,
                    "visits": 4025
                }
				
		<?php
        }
		*/
     
    }
		?>
            ];
			</script>
</div>

<div class = "row" >
<?php
$SHParams = array(
      'dimensions' => 'ga:hour',
      
      'sort' => '-ga:sessions',
      'max-results' => '25');
$resultsSH = $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-11-01',
       '2014-11-15',
	   'ga:sessions',
       $SHParams
	   );
	   


?>
		<script type="text/javascript">
            var chartData = [
		<?php
    // Print table rows.
	$x=1;
    foreach ($resultsSH->getRows() as $row) {
      
		?>
                {
                    "hour": "<?php echo $row[0]; ?>",
                    "visits": <?php echo $row[1]; ?>
                }
		<?php
				if($x>=sizeof($resultsSH->getRows()))
				{
				?>
				<?php
				}
				else
				{
				?>
				,
				<?php
				}
				$x++;
	  /*
        foreach ($row as $cell) {
          $table .= '<td>'
                 . htmlspecialchars($cell, ENT_NOQUOTES)
                 . '</td>';
		?>
                {
                    "hour": <?php echo htmlentities($cell); ?>,
                    "visits": 4025
                }
				
		<?php
        }
		*/
     
    }
		?>
            ];
			</script>

</div>


<script src="amcharts/amcharts.js" type="text/javascript"></script>
        <script src="amcharts/serial.js" type="text/javascript"></script>

        <script type="text/javascript">
            var chart;

            AmCharts.ready(function () {
                // SERIAL CHART
                chart = new AmCharts.AmSerialChart();
                chart.dataProvider = chartData;
                chart.categoryField = "hour";
                chart.startDuration = 1;

                // AXES
                // category
                var categoryAxis = chart.categoryAxis;
                categoryAxis.labelRotation = 90;
                categoryAxis.gridPosition = "start";

                // value
                // in case you don't want to change default settings of value axis,
                // you don't need to create it, as one value axis is created automatically.

                // GRAPH
                var graph = new AmCharts.AmGraph();
                graph.valueField = "visits";
                graph.balloonText = "[[category]]: <b>[[value]]</b>";
                graph.type = "column";
                graph.lineAlpha = 0;
                graph.fillAlphas = 0.8;
                chart.addGraph(graph);

                // CURSOR
                var chartCursor = new AmCharts.ChartCursor();
                chartCursor.cursorAlpha = 0;
                chartCursor.zoomable = false;
                chartCursor.categoryBalloonEnabled = false;
                chart.addChartCursor(chartCursor);

                chart.creditsPosition = "top-right";

                chart.write("chart");
            });
        </script>
		<script type="text/javascript">
            var charta;

            AmCharts.ready(function () {
                // SERIAL CHART
                charta = new AmCharts.AmSerialChart();
                charta.dataProvider = chartData1;
                charta.categoryField = "pagePath";
                charta.startDuration = 1;

                // AXES
                // category
                var categoryAxisa = charta.categoryAxis;
                categoryAxisa.labelRotation = 90;
                categoryAxisa.gridPosition = "start";

                // value
                // in case you don't want to change default settings of value axis,
                // you don't need to create it, as one value axis is created automatically.

                // GRAPH
                var grapha = new AmCharts.AmGraph();
                grapha.valueField = "pageView";
                grapha.balloonText = "[[category]]: <b>[[value]]</b>";
                grapha.type = "column";
                grapha.lineAlpha = 0;
                grapha.fillAlphas = 0.8;
                charta.addGraph(grapha);

                // CURSOR
                var chartCursora = new AmCharts.ChartCursor();
                chartCursora.cursorAlpha = 0;
                chartCursora.zoomable = false;
                chartCursora.categoryBalloonEnabled = false;
                charta.addChartCursor(chartCursora);

                charta.creditsPosition = "top-right";

                charta.write("charta");
            });
        </script>
				<script type="text/javascript">
            var chartb;

            AmCharts.ready(function () {
                // SERIAL CHART
                chartb = new AmCharts.AmSerialChart();
                chartb.dataProvider = chartData2;
                chartb.categoryField = "date";
                chartb.startDuration = 1;

                // AXES
                // category
                var categoryAxisb = chartb.categoryAxis;
                categoryAxisb.labelRotation = 90;
                categoryAxisb.gridPosition = "start";

                // value
                // in case you don't want to change default settings of value axis,
                // you don't need to create it, as one value axis is created automatically.

                // GRAPH
                var graphb = new AmCharts.AmGraph();
                graphb.valueField = "pageviews";
                graphb.balloonText = "[[category]]: <b>[[value]]</b>";
                graphb.type = "column";
                graphb.lineAlpha = 0;
                graphb.fillAlphas = 0.8;
                chartb.addGraph(graphb);

                // CURSOR
                var chartCursorb = new AmCharts.ChartCursor();
                chartCursorb.cursorAlpha = 0;
                chartCursorb.zoomable = false;
                chartCursorb.categoryBalloonEnabled = false;
                chartb.addChartCursor(chartCursorb);

                chartb.creditsPosition = "top-right";

                chartb.write("chartb");
            });
        </script>S
		<div class = "row" >

<div id="chart" style="width: 100%; height: 400px;"></div>
</div>
<div class = "row" >

<div id="charta" style="width: 100% ; height: 800px;"></div>
</div>

<div class = "row" >

<div id="chartb" style="width: 100% ; height: 400px;"></div>
</div>

<div class = "row" >


</div>
